<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use kartik\select2\Select2;
use yii\helpers\ArrayHelper;
use yii\widgets\Pjax;
use yii\grid\GridView;

/* @var $this yii\web\View */
/* @var $searchModel app\models\GkyGroupMsgSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = 'Gky Group Msgs';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="gky-group-msg-index">

    <?php // echo $this->render('_search', ['model' => $searchModel]); ?>

    <div class="col-md-12">      
        <?php
        $form = ActiveForm::begin([
                    'action' => ['index'],
                    'method' => 'get',
                    'options' => ['class' => 'input-group col-md-12'],
                    'fieldConfig' => [
                        'template' => '<div class="col-lg-12 col-md-12">{input}</div>',
                    ]
                ])
        ?>

       

        <div class="col-md-4">
            <label style="float: left;margin-top: 5px;">标题</label>
            <div style="overflow: hidden;">
                <?php
//                $data = app\models\GkyGroupMsg::find()->all();
//                echo $form->field($searchModel, 'title')->widget(Select2::classname(), [
//                    'data' => ArrayHelper::map($data, 'title', 'title'),
//                    'options' => ['placeholder' => '请输入内容'],
//                    'pluginOptions' => [
//                        'allowClear' => true
//                    ],
//                ]);
                ?>
                 <?php
                $projects = app\models\GkyGroupMsg::find()->all();
                foreach ($projects as $item) {
                    $source[] = $item->title;
                }
                echo yii\jui\AutoComplete::widget([
                    'model' => $searchModel,
                    'attribute' => 'title',
                    'options'=>['style'=>'margin-left:10px'],
                    'clientOptions' => [
                        'source' => $source,
                    ],
                ]);
                ?>       
            </div>
        </div>

        <div class="col-md-1 text-center">
            <?= Html::submitButton('搜索', ['class' => 'btn btn-primary']) ?> 
        </div>
        
        <div class="col-md-1 text-center">
          <?= Html::a('添加', ['create'], ['class' => 'btn btn-primary']) ?> 
        </div>

    </div>

    <div class="col-md-12 text-right" style="margin: 15px 0 15px 15px;">
    </div>
    
    <?php ActiveForm::end(); ?>    
    <?php Pjax::begin(); ?>
    <?= GridView::widget([
        'tableOptions' => ['class' => 'table table-bordered'],
        'rowOptions' => [
            'style' => '
                        border-bottom: 18px solid #EFEFEF;
                        white-space: nowrap;
                        overflow: hidden;
                        text-overflow: ellipsis;
                        height: 50px;
                        '],
        'headerRowOptions' => [
            'style' => 'font-size: 15px;color: #2a70e9;background-color: #D9EDF7;',
        ],
        'layout' => "{items}\n{pager}",
        'dataProvider' => $dataProvider,
        'columns' => [
         //   ['class' => 'yii\grid\SerialColumn'],

//            'id',
//            'weid',
            'wename',
            'title',
//            'addtime',
//            'sendtime',
        //    'sendcount',
            'msg:ntext',
//             'media_id',

            [
                'class' => 'app\common\widgets\ActionColumn',
                'template' => ' {:update} {:delete} {:send}',
                'buttons' => [
                  
                    //view button
                    'send' => function ($url) {
                        return Html::a('<span class="fa fa-search"></span>发送', $url, [
                                    'title' => Yii::t('app', '发送'),
//                                    'class' => 'btn btn-primary btn-xs',
                        ]);
                    },
                            //update button
                            'update' => function ($url) {
                        return Html::a('<span class="fa fa-search"></span>更新', $url, [
                                    'title' => Yii::t('app', '更新'),
//                                    'class' => 'btn btn-primary btn-xs',
                        ]);
                    },
                            //update button
                            'delete' => function ($url) {
                        return Html::a('<span class="fa fa-search"></span>删除', $url, [
                                    'title' => Yii::t('app', '删除'),
                                    'data-confirm' => Yii::t('yii', 'Are you sure you want to delete this item?'),
                                    'data-method' => 'post',
                                    'data-pjax' => '0',
//                                    'class' => 'btn btn-primary btn-xs',
                        ]);
                    },
                    
                        ],
               
            ],
        ],
    ]); ?>
<?php Pjax::end(); ?>
</div>
